package top.go2do.goods.business.goods.module;

import jakarta.persistence.*;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @Description
 * @Author xingyj
 * @CreateTime 2025/6/18 12:45
 */
@Entity
@Table(name = "goods_tags")
@IdClass(GoodsTagId.class)
@Data
public class GoodsTagPO {

    @Id
    @Column(name = "goods_id", columnDefinition = "BIGINT UNSIGNED COMMENT '实体ID(雪花算法分布式ID)'")
    private Long goodsId;

    @Id
    @Column(name = "tag_id", columnDefinition = "BIGINT UNSIGNED COMMENT '标签ID(雪花算法分布式ID)'")
    private Long tagId;

    @Id
    @Column(name = "app_id", nullable = false, columnDefinition = "VARCHAR(32) COMMENT '所属应用ID'")
    private String appId;

    @Column(name = "sort", columnDefinition = "INT DEFAULT '1' COMMENT '排序权重'")
    private Integer sort;

    @Column(name = "created_at", nullable = false, insertable = false, updatable = false,
            columnDefinition = "DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6) COMMENT '创建时间'")
    private LocalDateTime createdAt;

}

class GoodsTagId implements Serializable {
    private Long goodsId;
    private Long tagId;
    private String appId;
}
